package interfaceComUsuario;

import javax.swing.JInternalFrame;
import java.awt.BorderLayout;
import javax.swing.JDesktopPane;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JTextArea;

import java.awt.Color;
import java.io.PrintStream;

import javax.swing.JTextField;

public class FrameFichaDeadlands extends JInternalFrame
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2414633352817568476L;
	private JTextField textField_NomeDoPersonagem;
	private JTextField textField_NomeDoJogador;
	private JTextField textField_Ocupacao;
	private JTextField textField_Cognition;
	private JTextField textField_Knowledge;
	private JTextField textField_Mien;
	private JTextField textField_Smarts;
	private JTextField textField_Spirit;
	private JTextField textField_Deftness;
	private JTextField textField_Nimbleness;
	private JTextField textField_Strength;
	private JTextField textField_Quickness;
	private JTextField textField_Vigor;
	private TextAreaPrintStream saida;

	/**
	 * Create the frame.
	 */
	public FrameFichaDeadlands(JTextArea saida)
	{
		this.saida = new TextAreaPrintStream(saida, System.out);
		setBounds(0, 0, 928, 590);
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		getContentPane().add(tabbedPane, BorderLayout.CENTER);
		
		JDesktopPane desktopPane = new JDesktopPane();
		tabbedPane.addTab("B\u00E1sico", null, desktopPane, null);
		
		JLabel lblNomeDoPersonagem = new JLabel("Nome do Personagem");
		lblNomeDoPersonagem.setForeground(Color.BLACK);
		lblNomeDoPersonagem.setBounds(23, 66, 215, 14);
		desktopPane.add(lblNomeDoPersonagem);
		
		textField_NomeDoPersonagem = new JTextField();
		textField_NomeDoPersonagem.setBounds(23, 82, 216, 20);
		desktopPane.add(textField_NomeDoPersonagem);
		textField_NomeDoPersonagem.setColumns(10);
		
		textField_NomeDoJogador = new JTextField();
		textField_NomeDoJogador.setColumns(10);
		textField_NomeDoJogador.setBounds(23, 42, 216, 20);
		desktopPane.add(textField_NomeDoJogador);
		
		JLabel lblNomeDoJogador = new JLabel("Nome do Jogador");
		lblNomeDoJogador.setForeground(Color.BLACK);
		lblNomeDoJogador.setBounds(23, 26, 215, 14);
		desktopPane.add(lblNomeDoJogador);
		
		textField_Ocupacao = new JTextField();
		textField_Ocupacao.setColumns(10);
		textField_Ocupacao.setBounds(23, 124, 216, 20);
		desktopPane.add(textField_Ocupacao);
		
		JLabel lblOcupao = new JLabel("Ocupa\u00E7\u00E3o");
		lblOcupao.setForeground(Color.BLACK);
		lblOcupao.setBounds(23, 108, 215, 14);
		desktopPane.add(lblOcupao);
		
		JDesktopPane desktopPane_2 = new JDesktopPane();
		tabbedPane.addTab("Atributos", null, desktopPane_2, null);
		
		textField_Cognition = new JTextField();
		textField_Knowledge = new JTextField();
		textField_Mien = new JTextField();
		textField_Smarts = new JTextField();
		textField_Spirit = new JTextField();
		textField_Deftness = new JTextField();
		textField_Nimbleness = new JTextField();
		textField_Strength = new JTextField();
		textField_Quickness = new JTextField();
		textField_Vigor = new JTextField();
		
		Clicavel interacao_Cognition;
		Clicavel interacao_Knowledge;
		Clicavel interacao_Mien;
		Clicavel interacao_Smarts;
		Clicavel interacao_Spirit;
		Clicavel interacao_Deftness;
		Clicavel interacao_Nimbleness;
		Clicavel interacao_Strength;
		Clicavel interacao_Quickness;
		Clicavel interacao_Vigor;
		
		JLabel lblCogdice = new JLabel("CogDice");
		JLabel lblDefdice = new JLabel("DefDice");
		JLabel lblNimdice = new JLabel("NimDice");
		JLabel lblKnodice = new JLabel("KnoDice");
		JLabel lblMiedice = new JLabel("MieDice");
		JLabel lblStrdice = new JLabel("StrDice");
		JLabel lblQuidice = new JLabel("QuiDice");
		JLabel lblSmadice = new JLabel("SmaDice");
		JLabel lblSpidice = new JLabel("SpiDice");
		JLabel lblVigdice = new JLabel("VigDice");
		
		interacao_Cognition = criarLabelAtivo(desktopPane_2, lblCogdice, textField_Cognition, "Cognition", 77, 25, this.saida);
		interacao_Knowledge = criarLabelAtivo(desktopPane_2, lblKnodice, textField_Knowledge, "Knowlodge", 232, 25, this.saida);
		interacao_Mien = criarLabelAtivo(desktopPane_2, lblMiedice, textField_Mien, "Mien", 410, 25, this.saida);
		interacao_Smarts = criarLabelAtivo(desktopPane_2, lblSmadice, textField_Smarts, "Smarts", 565, 25, this.saida);
		interacao_Spirit = criarLabelAtivo(desktopPane_2, lblSpidice, textField_Spirit, "Spirit", 720, 25, this.saida);
		interacao_Deftness = criarLabelAtivo(desktopPane_2, lblDefdice, textField_Deftness, "Deftness", 77, 280, this.saida);
		interacao_Nimbleness = criarLabelAtivo(desktopPane_2, lblNimdice, textField_Nimbleness, "Nimbleness", 232, 280, this.saida);
		interacao_Strength = criarLabelAtivo(desktopPane_2, lblStrdice, textField_Strength, "Strength", 410, 280, this.saida);
		interacao_Quickness = criarLabelAtivo(desktopPane_2, lblQuidice, textField_Quickness, "Quickness", 565, 280, this.saida);
		interacao_Vigor = criarLabelAtivo(desktopPane_2, lblVigdice, textField_Vigor, "Vigor", 720, 280, this.saida);
		
		boolean editavel = false;
		
		textField_Cognition.setEditable(editavel);
		textField_Cognition.setBounds(77, 79, 86, 20);
		desktopPane_2.add(textField_Cognition);
		textField_Cognition.setColumns(10);
		
		textField_Knowledge.setEditable(editavel);
		textField_Knowledge.setColumns(10);
		textField_Knowledge.setBounds(232, 79, 86, 20);
		desktopPane_2.add(textField_Knowledge);
		
		textField_Mien.setEditable(editavel);
		textField_Mien.setColumns(10);
		textField_Mien.setBounds(410, 79, 86, 20);
		desktopPane_2.add(textField_Mien);
		
		textField_Smarts.setEditable(editavel);
		textField_Smarts.setColumns(10);
		textField_Smarts.setBounds(565, 79, 86, 20);
		desktopPane_2.add(textField_Smarts);
		
		textField_Spirit.setEditable(editavel);
		textField_Spirit.setColumns(10);
		textField_Spirit.setBounds(720, 79, 86, 20);
		desktopPane_2.add(textField_Spirit);
		
		textField_Deftness.setEditable(editavel);
		textField_Deftness.setColumns(10);
		textField_Deftness.setBounds(77, 341, 86, 20);
		desktopPane_2.add(textField_Deftness);
		
		textField_Nimbleness.setEditable(editavel);
		textField_Nimbleness.setColumns(10);
		textField_Nimbleness.setBounds(232, 341, 86, 20);
		desktopPane_2.add(textField_Nimbleness);
		
		textField_Strength.setEditable(editavel);
		textField_Strength.setColumns(10);
		textField_Strength.setBounds(410, 341, 86, 20);
		desktopPane_2.add(textField_Strength);
		
		textField_Quickness.setEditable(editavel);
		textField_Quickness.setColumns(10);
		textField_Quickness.setBounds(565, 341, 86, 20);
		desktopPane_2.add(textField_Quickness);
		
		textField_Vigor.setEditable(editavel);
		textField_Vigor.setColumns(10);
		textField_Vigor.setBounds(720, 341, 86, 20);
		desktopPane_2.add(textField_Vigor);
		
		lblCogdice.setForeground(Color.BLACK);
		lblCogdice.setBounds(77, 134, 86, 14);
		desktopPane_2.add(lblCogdice);
		
		lblDefdice.setForeground(Color.BLACK);
		lblDefdice.setBounds(77, 389, 86, 14);
		desktopPane_2.add(lblDefdice);
		
		lblNimdice.setForeground(Color.BLACK);
		lblNimdice.setBounds(232, 389, 86, 14);
		desktopPane_2.add(lblNimdice);
		
		lblKnodice.setForeground(Color.BLACK);
		lblKnodice.setBounds(232, 134, 69, 14);
		desktopPane_2.add(lblKnodice);
		
		lblMiedice.setForeground(Color.BLACK);
		lblMiedice.setBounds(410, 134, 46, 14);
		desktopPane_2.add(lblMiedice);
		
		lblStrdice.setForeground(Color.BLACK);
		lblStrdice.setBounds(410, 389, 86, 14);
		desktopPane_2.add(lblStrdice);
		
		lblQuidice.setForeground(Color.BLACK);
		lblQuidice.setBounds(565, 389, 77, 14);
		desktopPane_2.add(lblQuidice);
		
		lblSmadice.setForeground(Color.BLACK);
		lblSmadice.setBounds(565, 134, 86, 14);
		desktopPane_2.add(lblSmadice);
		
		lblSpidice.setForeground(Color.BLACK);
		lblSpidice.setBounds(720, 134, 46, 14);
		desktopPane_2.add(lblSpidice);
		
		lblVigdice.setForeground(Color.BLACK);
		lblVigdice.setBounds(720, 389, 46, 14);
		desktopPane_2.add(lblVigdice);
		
		JDesktopPane desktopPane_1 = new JDesktopPane();
		tabbedPane.addTab("Per\u00EDcias", null, desktopPane_1, null);
	}

	/**
	 * @param desktopPane_2
	 * @param lblCogdice
	 */
	private Clicavel criarLabelAtivo(JDesktopPane desktopPane_2, JLabel lblCogdice,
			                     JTextField textField, String nome,
			                     int x, int y, PrintStream saida)
	{
		LabelCarta label;
		label = new LabelCarta(nome, textField, lblCogdice, null);
		label.setForeground(Color.BLACK);
		label.setBounds(x, y, 90, 14);
		Clicavel clicavel = criarMouseListener(label, saida);
		desktopPane_2.add(label);
		return clicavel;
	}

	/**
	 * @param label
	 */
	private Clicavel criarMouseListener(LabelCarta label, PrintStream saida)
	{
		Clicavel clicavel;
		label.getText();
		clicavel = new Clicavel(saida);
		label.addMouseListener(clicavel);
		return clicavel;
	}
}
